ENSAE Pierre NDIAYE de Dakar ISE1-Cycle long 2024-2025 COURS DE Statistique exploratoire spaciale avec M.Aboubacre HEMA Devoir de maison de la séance 2 : Cours du vendredi 18 octobre 2024 Groupe : Logiciel R Pays : Burkina Faso Composé de : Ange Emilson Rayan RAHERINASOLO, Khadidiatou DIAKHATE, Alioune Abdou Salam KANE et Awa DIAW

           ============== CONSIGNE =================

#Section 1 : Données vectorielles #

1. Importation des données

2. Calculs de statistiques

a. Nombre de géométries par niveau

b. Projection et Système de Référence de Coordonnées (CRS)

c. Etendue (longitude et latitude min/max)

d. Centroides ( déjà calculer pour chaque niveau durant le tp1)

e. Aire et Périmètre

3. Visualisation : Afficher les données vectorielles

============== =================

Section 1 : Données vectorielles

1.Importation des données shapefile pour les régions du Burkina Faso

# Charger les bibliothèques nécessaires

library(sf) 
## Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE
library(dplyr) 
## 
## Attachement du package : 'dplyr'
## Les objets suivants sont masqués depuis 'package:stats':
## 
##     filter, lag
## Les objets suivants sont masqués depuis 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)

# Définir le chemin de base pour éviter la répétition

chemin_base <- "C:/Users/ALIOUNE KANE/Downloads/ENSAE/ISEP3/Statistiques exploratoire et spatiale/bfa_adm_igb_20200323_shp/"

# Importer les shapefiles

burkinafaso <- st_read(paste0(chemin_base, "bfa_admbnda_adm0_igb_20200323.shp")) 
## Reading layer `bfa_admbnda_adm0_igb_20200323' from data source 
##   `C:\Users\ALIOUNE KANE\Downloads\ENSAE\ISEP3\Statistiques exploratoire et spatiale\bfa_adm_igb_20200323_shp\bfa_admbnda_adm0_igb_20200323.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 1 feature and 10 fields
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: -5.511255 ymin: 9.415337 xmax: 2.407427 ymax: 15.08311
## Geodetic CRS:  WGS 84
regionbf <- st_read(paste0(chemin_base, "bfa_admbnda_adm1_igb_20200323.shp")) 
## Reading layer `bfa_admbnda_adm1_igb_20200323' from data source 
##   `C:\Users\ALIOUNE KANE\Downloads\ENSAE\ISEP3\Statistiques exploratoire et spatiale\bfa_adm_igb_20200323_shp\bfa_admbnda_adm1_igb_20200323.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 13 features and 12 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -5.511255 ymin: 9.415337 xmax: 2.407427 ymax: 15.08311
## Geodetic CRS:  WGS 84
provincebf <- st_read(paste0(chemin_base, "bfa_admbnda_adm2_igb_20200323.shp")) 
## Reading layer `bfa_admbnda_adm2_igb_20200323' from data source 
##   `C:\Users\ALIOUNE KANE\Downloads\ENSAE\ISEP3\Statistiques exploratoire et spatiale\bfa_adm_igb_20200323_shp\bfa_admbnda_adm2_igb_20200323.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 45 features and 14 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -5.511255 ymin: 9.415337 xmax: 2.407427 ymax: 15.08311
## Geodetic CRS:  WGS 84
communebf <- st_read(paste0(chemin_base, "bfa_admbnda_adm3_igb_20200323.shp"))
## Reading layer `bfa_admbnda_adm3_igb_20200323' from data source 
##   `C:\Users\ALIOUNE KANE\Downloads\ENSAE\ISEP3\Statistiques exploratoire et spatiale\bfa_adm_igb_20200323_shp\bfa_admbnda_adm3_igb_20200323.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 351 features and 16 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -5.511255 ymin: 9.415337 xmax: 2.407427 ymax: 15.08311
## Geodetic CRS:  WGS 84

2.Calculs de statistiques

a.Nombre de géométries par niveau

Les géométries représentent la forme et la position des entités géographiques (point, ligne, polygone). Dans chaque shapefile, chaque ligne correspond à une entité géographique, et la colonne “geometry” contient la forme de cette entité. Le nombre de géométries est le nombre total d’entités géographiques.

#Calculer et afficher le nombre de géométries par niveau
print(paste("Nombre de géométries pour le Burkina Faso (niveau pays) :", nrow(burkinafaso))) 
## [1] "Nombre de géométries pour le Burkina Faso (niveau pays) : 1"
print(paste("Nombre de géométries pour les régions du Burkina Faso :", nrow(regionbf))) 
## [1] "Nombre de géométries pour les régions du Burkina Faso : 13"
print(paste("Nombre de géométries pour les provinces du Burkina Faso :", nrow(provincebf))) 
## [1] "Nombre de géométries pour les provinces du Burkina Faso : 45"
print(paste("Nombre de géométries pour les communes du Burkina Faso :", nrow(communebf)))
## [1] "Nombre de géométries pour les communes du Burkina Faso : 351"

b. Projection et Système de Référence de Coordonnées (CRS)

# Afficher la projection et le système de référence de coordonnées (CRS) pour chaque shapefile

print("Projection et Système de Référence de Coordonnées (CRS) :") 
## [1] "Projection et Système de Référence de Coordonnées (CRS) :"
print(paste("CRS pour le Burkina Faso (niveau pays) :", st_crs(burkinafaso)$proj4string))
## [1] "CRS pour le Burkina Faso (niveau pays) : +proj=longlat +datum=WGS84 +no_defs"
print(paste("CRS pour les régions du Burkina Faso :", st_crs(regionbf)$proj4string)) 
## [1] "CRS pour les régions du Burkina Faso : +proj=longlat +datum=WGS84 +no_defs"
print(paste("CRS pour les provinces du Burkina Faso :", st_crs(provincebf)$proj4string))
## [1] "CRS pour les provinces du Burkina Faso : +proj=longlat +datum=WGS84 +no_defs"
print(paste("CRS pour les communes du Burkina Faso :", st_crs(communebf)$proj4string))
## [1] "CRS pour les communes du Burkina Faso : +proj=longlat +datum=WGS84 +no_defs"

c. Etendue (longitude et latitude min/max)

#Calculer et afficher l'étendue (longitude et latitude min/max) pour chaque shapefile sous forme de data frame
etendue_burkinafaso <- data.frame( Coordonnée = c("xmin", "xmax", "ymin", "ymax"), Valeur = c(st_bbox(burkinafaso)["xmin"], st_bbox(burkinafaso)["xmax"], st_bbox(burkinafaso)["ymin"], st_bbox(burkinafaso)["ymax"]) ) 
print("Étendue pour le Burkina Faso (niveau pays) :")
## [1] "Étendue pour le Burkina Faso (niveau pays) :"
print(etendue_burkinafaso)
##      Coordonnée    Valeur
## xmin       xmin -5.511255
## xmax       xmax  2.407427
## ymin       ymin  9.415337
## ymax       ymax 15.083105
etendue_regionbf <- data.frame( Coordonnée = c("xmin", "xmax", "ymin", "ymax"), Valeur = c(st_bbox(regionbf)["xmin"], st_bbox(regionbf)["xmax"], st_bbox(regionbf)["ymin"], st_bbox(regionbf)["ymax"]) ) 
print("Étendue pour les régions du Burkina Faso :") 
## [1] "Étendue pour les régions du Burkina Faso :"
print(etendue_regionbf)
##      Coordonnée    Valeur
## xmin       xmin -5.511255
## xmax       xmax  2.407427
## ymin       ymin  9.415337
## ymax       ymax 15.083105
etendue_provincebf <- data.frame( Coordonnée = c("xmin", "xmax", "ymin", "ymax"), Valeur = c(st_bbox(provincebf)["xmin"], st_bbox(provincebf)["xmax"], st_bbox(provincebf)["ymin"], st_bbox(provincebf)["ymax"]) ) 
print("Étendue pour les provinces du Burkina Faso :") 
## [1] "Étendue pour les provinces du Burkina Faso :"
print(etendue_provincebf)
##      Coordonnée    Valeur
## xmin       xmin -5.511255
## xmax       xmax  2.407427
## ymin       ymin  9.415337
## ymax       ymax 15.083105
etendue_communebf <- data.frame( Coordonnée = c("xmin", "xmax", "ymin", "ymax"), Valeur = c(st_bbox(communebf)["xmin"], st_bbox(communebf)["xmax"], st_bbox(communebf)["ymin"], st_bbox(communebf)["ymax"]) ) 
print("Étendue pour les communes du Burkina Faso :") 
## [1] "Étendue pour les communes du Burkina Faso :"
print(etendue_communebf)
##      Coordonnée    Valeur
## xmin       xmin -5.511255
## xmax       xmax  2.407427
## ymin       ymin  9.415337
## ymax       ymax 15.083105

d. Calcul des centroides

# Calculer et afficher les centroides pour chaque niveau administratif

centroides_burkinafaso <- st_centroid(burkinafaso) 
## Warning: st_centroid assumes attributes are constant over geometries
print("Centroides pour le Burkina Faso (niveau pays) :") 
## [1] "Centroides pour le Burkina Faso (niveau pays) :"
print(centroides_burkinafaso)
## Simple feature collection with 1 feature and 10 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: -1.741371 ymin: 12.27491 xmax: -1.741371 ymax: 12.27491
## Geodetic CRS:  WGS 84
##   Shape_Leng Shape_Area      ADM0_FR ADM0_PCODE ADM0_REF ADM0ALT1FR ADM0ALT2FR
## 1   34.28192   22.70596 Burkina Faso         BF     <NA>       <NA>       <NA>
##         date    validOn    validTo                   geometry
## 1 2020-03-18 2020-03-23 -001-11-30 POINT (-1.741371 12.27491)
centroides_regionbf <- st_centroid(regionbf) 
## Warning: st_centroid assumes attributes are constant over geometries
print("Centroides pour les régions du Burkina Faso :") 
## [1] "Centroides pour les régions du Burkina Faso :"
print(centroides_regionbf)
## Simple feature collection with 13 features and 12 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: -4.570146 ymin: 10.3545 xmax: 0.9276577 ymax: 14.14784
## Geodetic CRS:  WGS 84
## First 10 features:
##    Shape_Leng Shape_Area           ADM1_FR ADM1_PCODE ADM1_REF ADM1ALT1FR
## 1   12.979104  2.8667334 Boucle du Mouhoun       BF46     <NA>       <NA>
## 2    9.431868  1.5094699          Cascades       BF47     <NA>       <NA>
## 3    3.287168  0.2483021            Centre       BF13     <NA>       <NA>
## 4    8.425414  1.2013236        Centre-Est       BF48     <NA>       <NA>
## 5    7.905622  1.6466027       Centre-Nord       BF49     <NA>       <NA>
## 6   10.232425  1.8005693      Centre-Ouest       BF50     <NA>       <NA>
## 7    7.087421  0.9603542        Centre-Sud       BF51     <NA>       <NA>
## 8   14.563574  3.9589245               Est       BF52     <NA>       <NA>
## 9   10.947066  2.0985389     Hauts-Bassins       BF53     <NA>       <NA>
## 10   7.099446  1.3762247              Nord       BF54     <NA>       <NA>
##    ADM1ALT2FR      ADM0_FR ADM0_PCODE       date    validOn    validTo
## 1        <NA> Burkina Faso         BF 2020-03-18 2020-03-23 -001-11-30
## 2        <NA> Burkina Faso         BF 2020-03-18 2020-03-23 -001-11-30
## 3        <NA> Burkina Faso         BF 2020-03-18 2020-03-23 -001-11-30
## 4        <NA> Burkina Faso         BF 2020-03-18 2020-03-23 -001-11-30
## 5        <NA> Burkina Faso         BF 2020-03-18 2020-03-23 -001-11-30
## 6        <NA> Burkina Faso         BF 2020-03-18 2020-03-23 -001-11-30
## 7        <NA> Burkina Faso         BF 2020-03-18 2020-03-23 -001-11-30
## 8        <NA> Burkina Faso         BF 2020-03-18 2020-03-23 -001-11-30
## 9        <NA> Burkina Faso         BF 2020-03-18 2020-03-23 -001-11-30
## 10       <NA> Burkina Faso         BF 2020-03-18 2020-03-23 -001-11-30
##                      geometry
## 1  POINT (-3.489087 12.53526)
## 2   POINT (-4.570146 10.3545)
## 3  POINT (-1.499954 12.32587)
## 4  POINT (-0.1858079 11.6073)
## 5  POINT (-0.973315 13.27092)
## 6  POINT (-2.221183 11.79551)
## 7  POINT (-1.218683 11.58375)
## 8  POINT (0.9276577 12.23993)
## 9  POINT (-4.331126 11.36539)
## 10 POINT (-2.282889 13.45939)
centroides_provincebf <- st_centroid(provincebf) 
## Warning: st_centroid assumes attributes are constant over geometries
print("Centroides pour les provinces du Burkina Faso :") 
## [1] "Centroides pour les provinces du Burkina Faso :"
print(centroides_provincebf)
## Simple feature collection with 45 features and 14 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: -5.260124 ymin: 9.878312 xmax: 1.734711 ymax: 14.65538
## Geodetic CRS:  WGS 84
## First 10 features:
##    Shape_Leng Shape_Area    ADM2_FR ADM2_PCODE   ADM2_REF ADM2ALT1FR ADM2ALT2FR
## 1    5.080606  0.3760395       Balé     BF4601       Bale       <NA>       <NA>
## 2    3.082476  0.3334829        Bam     BF4901       <NA>       <NA>       <NA>
## 3    5.374185  0.4835195      Banwa     BF4602       <NA>       <NA>       <NA>
## 4    3.879035  0.3086405     Bazèga     BF5101     Bazega       <NA>       <NA>
## 5    3.351516  0.2273993 Bougouriba     BF5701       <NA>       <NA>       <NA>
## 6    5.544153  0.5264686    Boulgou     BF4801       <NA>       <NA>       <NA>
## 7    4.205287  0.3547214 Boulkiemdé     BF5001 Boulkiemde       <NA>       <NA>
## 8    8.456630  1.2614331      Comoé     BF4701      Comoe       <NA>       <NA>
## 9    3.691064  0.3574087 Ganzourgou     BF5501       <NA>       <NA>       <NA>
## 10   6.645653  0.7704353     Gnagna     BF5201       <NA>       <NA>       <NA>
##              ADM1_FR ADM1_PCODE      ADM0_FR ADM0_PCODE       date    validOn
## 1  Boucle du Mouhoun       BF46 Burkina Faso         BF 2020-03-18 2020-03-23
## 2        Centre-Nord       BF49 Burkina Faso         BF 2020-03-18 2020-03-23
## 3  Boucle du Mouhoun       BF46 Burkina Faso         BF 2020-03-18 2020-03-23
## 4         Centre-Sud       BF51 Burkina Faso         BF 2020-03-18 2020-03-23
## 5          Sud-Ouest       BF57 Burkina Faso         BF 2020-03-18 2020-03-23
## 6         Centre-Est       BF48 Burkina Faso         BF 2020-03-18 2020-03-23
## 7       Centre-Ouest       BF50 Burkina Faso         BF 2020-03-18 2020-03-23
## 8           Cascades       BF47 Burkina Faso         BF 2020-03-18 2020-03-23
## 9    Plateau-Central       BF55 Burkina Faso         BF 2020-03-18 2020-03-23
## 10               Est       BF52 Burkina Faso         BF 2020-03-18 2020-03-23
##       validTo                    geometry
## 1  -001-11-30  POINT (-3.075673 11.72428)
## 2  -001-11-30  POINT (-1.585808 13.47174)
## 3  -001-11-30  POINT (-4.166819 12.25044)
## 4  -001-11-30  POINT (-1.478014 11.96369)
## 5  -001-11-30  POINT (-3.416751 10.84769)
## 6  -001-11-30 POINT (-0.4451432 11.50586)
## 7  -001-11-30  POINT (-2.148858 12.31479)
## 8  -001-11-30   POINT (-4.434745 10.3034)
## 9  -001-11-30   POINT (-0.769333 12.2533)
## 10 -001-11-30 POINT (0.04851296 12.93234)
centroides_communebf <- st_centroid(communebf) 
## Warning: st_centroid assumes attributes are constant over geometries
print("Centroides pour les communes du Burkina Faso :") 
## [1] "Centroides pour les communes du Burkina Faso :"
print(centroides_communebf)
## Simple feature collection with 351 features and 16 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: -5.384677 ymin: 9.582955 xmax: 2.03659 ymax: 14.93353
## Geodetic CRS:  WGS 84
## First 10 features:
##    Shape_Leng Shape_Area    ADM3_FR ADM3_PCODE ADM3_REF ADM3ALT1FR ADM3ALT2FR
## 1   0.9225350 0.02567560   Ambsouya   BF550301     <NA>       <NA>       <NA>
## 2   1.5092847 0.05880498 Andemtenga   BF480301     <NA>       <NA>       <NA>
## 3   2.6049904 0.23737491    Arbinda   BF560301     <NA>       <NA>       <NA>
## 4   1.2181921 0.05467909    Arbollé   BF540201  Arbolle       <NA>       <NA>
## 5   0.8103855 0.03835600     Bagaré   BF540202   Bagare       <NA>       <NA>
## 6   1.2960298 0.05265190    Bagassi   BF460101     <NA>       <NA>       <NA>
## 7   0.8904664 0.03335673      Bagré   BF480101    Bagre       <NA>       <NA>
## 8   1.7634231 0.10179216       Bahn   BF540101     <NA>       <NA>       <NA>
## 9   1.2380514 0.05121533     Bakata   BF500401     <NA>       <NA>       <NA>
## 10  1.1227106 0.04575601     Balavé   BF460201   Balave       <NA>       <NA>
##        ADM2_FR ADM2_PCODE           ADM1_FR ADM1_PCODE      ADM0_FR ADM0_PCODE
## 1   Oubritenga     BF5503   Plateau-Central       BF55 Burkina Faso         BF
## 2  Kourittenga     BF4803        Centre-Est       BF48 Burkina Faso         BF
## 3         Soum     BF5603             Sahel       BF56 Burkina Faso         BF
## 4      Passoré     BF5402              Nord       BF54 Burkina Faso         BF
## 5      Passoré     BF5402              Nord       BF54 Burkina Faso         BF
## 6         Balé     BF4601 Boucle du Mouhoun       BF46 Burkina Faso         BF
## 7      Boulgou     BF4801        Centre-Est       BF48 Burkina Faso         BF
## 8       Loroum     BF5401              Nord       BF54 Burkina Faso         BF
## 9         Ziro     BF5004      Centre-Ouest       BF50 Burkina Faso         BF
## 10       Banwa     BF4602 Boucle du Mouhoun       BF46 Burkina Faso         BF
##          date    validOn    validTo                    geometry
## 1  2020-03-18 2020-03-23 -001-11-30 POINT (-0.9936096 12.58364)
## 2  2020-03-18 2020-03-23 -001-11-30 POINT (-0.2861834 12.38091)
## 3  2020-03-18 2020-03-23 -001-11-30 POINT (-0.8473258 14.16643)
## 4  2020-03-18 2020-03-23 -001-11-30  POINT (-2.019417 12.84047)
## 5  2020-03-18 2020-03-23 -001-11-30  POINT (-2.635516 12.89094)
## 6  2020-03-18 2020-03-23 -001-11-30  POINT (-3.262672 11.74342)
## 7  2020-03-18 2020-03-23 -001-11-30 POINT (-0.4738439 11.52026)
## 8  2020-03-18 2020-03-23 -001-11-30  POINT (-2.426967 14.12612)
## 9  2020-03-18 2020-03-23 -001-11-30  POINT (-1.865648 11.80525)
## 10 2020-03-18 2020-03-23 -001-11-30  POINT (-4.195009 12.38006)

e. Calcul de l’aire et du périmètre

# Calculer et organiser les résultats pour chaque région, province, et commune avec Aire et Périmètre

# Vérifier et caster le type de géométrie si nécessaire

if (!all(st_geometry_type(regionbf) == "MULTIPOLYGON")) { regionbf <- st_cast(regionbf, "MULTIPOLYGON") } 
if (!all(st_geometry_type(provincebf) == "MULTIPOLYGON")) { provincebf <- st_cast(provincebf, "MULTIPOLYGON") } 
if (!all(st_geometry_type(communebf) == "MULTIPOLYGON")) { communebf <- st_cast(communebf, "MULTIPOLYGON") }

# Calcul de l'aire et du périmètre

burkinafaso$area <- st_area(burkinafaso)
burkinafaso$perimeter <- st_length(st_boundary(burkinafaso)) 
glimpse(burkinafaso$area)
##  Units: [m^2] num 2.74e+11
glimpse(burkinafaso$perimeter)
##  Units: [m] num 3764583
regionbf$area <- st_area(regionbf)
regionbf$perimeter <- st_length(st_boundary(regionbf)) 
glimpse(regionbf$area)
##  Units: [m^2] num [1:13] 3.46e+10 1.84e+10 3.00e+09 1.45e+10 1.98e+10 ...
glimpse(regionbf$perimeter)
##  Units: [m] num [1:13] 1425918 1039838 361069 926681 866721 ...
provincebf$area <- st_area(provincebf)
provincebf$perimeter <- st_length(st_boundary(provincebf)) 
glimpse(provincebf$area)
##  Units: [m^2] num [1:45] 4.55e+09 4.01e+09 5.84e+09 3.73e+09 2.76e+09 ...
glimpse(provincebf$perimeter)
##  Units: [m] num [1:45] 558594 338234 590528 426126 369008 ...
communebf$area <- st_area(communebf)
communebf$perimeter <- st_length(st_boundary(communebf)) 
glimpse(communebf$area)
##  Units: [m^2] num [1:351] 3.10e+08 7.10e+08 2.85e+09 6.59e+08 4.62e+08 ...
glimpse(communebf$perimeter)
##  Units: [m] num [1:351] 101322 165820 285212 133858 89083 ...

Créer des tableaux pour les résultats

# Créer des tableaux pour les résultats
resultats_regionbf <- data.frame(
  region =regionbf$ADM1_FR,
  Aire = round(as.numeric(regionbf$area), 2),
  Perimetre = round(as.numeric(regionbf$perimeter), 2)
)
print("Aire et périmètre pour les régions du Burkina Faso :")
## [1] "Aire et périmètre pour les régions du Burkina Faso :"
print(resultats_regionbf)
##               region        Aire Perimetre
## 1  Boucle du Mouhoun 34598744851 1425917.7
## 2           Cascades 18359404805 1039837.8
## 3             Centre  2999318864  361068.8
## 4         Centre-Est 14549503915  926680.6
## 5        Centre-Nord 19815112301  866721.0
## 6       Centre-Ouest 21791925380 1123746.1
## 7         Centre-Sud 11632088230  778873.3
## 8                Est 47834492386 1600651.0
## 9      Hauts-Bassins 25437895873 1204222.3
## 10              Nord 16548276966  778208.6
## 11   Plateau-Central  8626177588  807810.4
## 12             Sahel 35496016853 1259410.4
## 13         Sud-Ouest 16580004047  927993.1
resultats_provincebf <- data.frame(
  Province = provincebf$ADM2_FR,
  Aire = round(as.numeric(provincebf$area), 2),
  Perimetre = round(as.numeric(provincebf$perimeter), 2)
)
print("Aire et périmètre pour les provinces du Burkina Faso :")
## [1] "Aire et périmètre pour les provinces du Burkina Faso :"
print(resultats_provincebf)
##       Province        Aire Perimetre
## 1         Balé  4552457500  558594.2
## 2          Bam  4009818803  338234.2
## 3        Banwa  5842224547  590527.6
## 4       Bazèga  3733241376  426126.2
## 5   Bougouriba  2761397499  369008.0
## 6      Boulgou  6378557800  610206.2
## 7   Boulkiemdé  4284954903  461413.4
## 8        Comoé 15345075316  932145.3
## 9   Ganzourgou  4318427634  405670.5
## 10      Gnagna  9284145877  729413.5
## 11      Gourma 11017908532  871596.9
## 12       Houet 11436290400  824241.3
## 13        Ioba  3306541187  388066.2
## 14     Kadiogo  2999318864  361068.8
## 15  Kénédougou  8431266358  549876.8
## 16  Komandjari  5112884488  510408.4
## 17   Kompienga  7014967696  609752.9
## 18       Kossi  7438192123  482640.3
## 19  Koulpélogo  5325567853  396152.8
## 20 Kourittenga  2845378262  355164.8
## 21   Kourwéogo  1615343954  261862.8
## 22      Léraba  3014329489  358425.4
## 23      Loroum  3774909863  342261.5
## 24     Mouhoun  7058602685  633773.6
## 25     Nahouri  3900516164  391505.2
## 26  Namentenga  6410524689  605710.9
## 27      Nayala  3715182967  304129.5
## 28    Noumbiel  2837867780  336927.1
## 29  Oubritenga  2692406000  379869.7
## 30     Oudalan  9746209169  481522.0
## 31     Passoré  3986585748  456161.8
## 32        Poni  7674197582  615476.0
## 33     Sanguié  5130401359  562000.0
## 34  Sanmatenga  9394768808  612448.8
## 35        Séno  6899467539  489855.4
## 36     Sissili  7132870279  658136.9
## 37        Soum 12519475073  552354.6
## 38      Sourou  5992085030  430701.2
## 39       Tapoa 15404585793  702520.9
## 40         Tuy  5570339115  528297.4
## 41       Yagha  6330865073  470122.9
## 42     Yatenga  6784185473  555379.2
## 43        Ziro  5243698840  398255.3
## 44     Zondoma  2002595882  279432.0
## 45  Zoundwéogo  3998330690  394787.9
resultats_communebf <- data.frame(
  Commune = communebf$ADM3_FR,
  Aire = round(as.numeric(communebf$area), 2),
  Perimetre = round(as.numeric(communebf$perimeter), 2)
)
print("Aire et périmètre pour les communes du Burkina Faso :")
## [1] "Aire et périmètre pour les communes du Burkina Faso :"
print(resultats_communebf)
##               Commune       Aire Perimetre
## 1            Ambsouya  309836315 101321.79
## 2          Andemtenga  710175352 165820.49
## 3             Arbinda 2845720152 285212.03
## 4             Arbollé  659164139 133858.23
## 5              Bagaré  462294067  89082.64
## 6             Bagassi  637379775 142711.04
## 7               Bagré  404125228  98102.95
## 8                Bahn 1220534171 192322.46
## 9              Bakata  619849191 136346.67
## 10             Balavé  552587596 123403.07
## 11               Bama 1246460645 208556.05
## 12               Bana  156517152  58404.89
## 13               Bané  459740727 134414.32
## 14            Banfora  936293085 151583.23
## 15               Bani 1488731992 232506.07
## 16             Banzon  126934341  80749.87
## 17          Baraboulé  841562275 138782.05
## 18             Barani 1969810716 238292.20
## 19              Barga  210316345  84466.44
## 20         Barsalogho 1878624880 278870.94
## 21       Bartiébougou  994066851 169220.51
## 22           Baskouré  120972731  65404.60
## 23              Bassi  208452214  73993.05
## 24              Batié 1232422925 211721.94
## 25            Béguédo   48338950  40189.08
## 26              Békui  490219896 129855.93
## 27               Béré  477038487 153071.54
## 28             Béréba  593634352 114348.62
## 29       Bérégadougou  279751592  97889.58
## 30              Bieha 1695517153 255565.87
## 31            Bilanga 2612872284 424174.96
## 32              Bindé  564309604 134510.93
## 33              Bingo  244082903  90704.26
## 34            Bissiga  303069094 103927.00
## 35              Bitou 1255645289 224979.16
## 36              Boala  462196899 114075.31
## 37     Bobo-Dioulasso 1785801684 267666.66
## 38            Bogandé 1428818394 249249.62
## 39              Boken  790015128 148155.78
## 40         Bomborokui  414190005  94983.88
## 41           Bondokui 1237571973 194685.12
## 42               Boni  381179181  99062.76
## 43             Boromo  979107348 174546.98
## 44              Botou 2009773883 257239.15
## 45             Boudri 1247480704 203541.23
## 46         Bougnounou  552694282 137155.78
## 47             Boulsa 1141330044 178100.30
## 48           Boundoré 1032459964 215891.89
## 49              Boura 1030594625 228694.77
## 50           Bourasso  666473066 169556.29
## 51            Bouroum 1156491249 199199.37
## 52    Bouroum-Bouroum  281983795 104749.85
## 53          Bourzanga 1091346879 155018.62
## 54             Boussé  452118835 140102.40
## 55           Bousséra  444176735 121829.98
## 56            Boussou  517654068 112822.51
## 57      Boussou-Koula  253953314 105451.46
## 58          Boussouma  360181296  87193.99
## 59          Boussouma  813928911 184823.10
## 60              Dablo  560965381 107658.12
## 61             Dakôrô  419412903 130770.87
## 62               Dalô  281096590  78419.27
## 63              Dandé  235392280  73467.86
## 64               Dano  639991362 147611.90
## 65           Dapeolgo  411213342 156540.51
## 66              Dargo  543058929 112455.49
## 67              Dassa  246250731  81873.70
## 68           Dédougou 1370250207 239682.55
## 69               Déou 2057368845 266015.26
## 70                 Di  311164925  83769.93
## 71              Diabo  750759349 160122.50
## 72           Dialgaye  390030529 106695.96
## 73            Diapaga 3527959831 335040.57
## 74          Diapangou  523327105 139230.10
## 75              Didyr  636157347 135947.81
## 76          Diébougou  597430365 179067.12
## 77             Diguel  530587349  97907.50
## 78            Dissihn  386882229  98524.21
## 79           Djibasso  854314729 156148.42
## 80              Djibo  955182457 256614.69
## 81            Djigouè  878762325 174028.38
## 82          Djigouèra  480576591 114424.97
## 83              Dokui  750162274 144365.47
## 84               Dolo  213297008  81028.72
## 85               Dori 2577766643 272769.81
## 86          Doulougou  521662276 175210.01
## 87           Doumbala  484561560 116514.03
## 88              Douna  174804580  57556.61
## 89           Douroula  475619035 124034.42
## 90          Dourtenga  118228463  57024.61
## 91       Fada-Ngourma 3475652898 350771.96
## 92        Falagountou  531677597 109022.82
## 93               Fara  711389963 155722.13
## 94           Faramana  220565789  90358.38
## 95                 Fo  427186525  91541.47
## 96            Founzan  782136361 162409.30
## 97           Foutouri 1465958007 205293.19
## 98                Gaô  508417114 108780.04
## 99             Gaongo  490084765 121544.45
## 100             Gaoua  771222719 154301.36
## 101           Garango  537843672 186465.55
## 102            Gassan 1034617503 175095.39
## 103            Gayéri 2652859630 331815.31
## 104         Gbomblora  662680881 156535.27
## 105        Gbondjigui  772111099 195126.85
## 106             Godyr  269294524  78177.06
## 107              Gogo 1088057586 184800.53
## 108           Gomboro  501042231 105175.12
## 109     Gomboussougou  773850835 154640.84
## 110         Gomponsom  232895606  66540.08
## 111          Gorgadji  951075113 154032.72
## 112       Gorom-Gorom 3064870584 348544.30
## 113           Gossina  418338685  81803.48
## 114          Gounguen  373252269 125801.74
## 115            Goursi  790105703 219938.13
## 116          Guéguéré  650503664 155076.88
## 117            Guiaro 1612618460 209552.35
## 118             Guiba  282046355 115211.30
## 119           Guibaré  242936250  86121.45
## 120            Houndé 1245788366 200579.78
## 121           Imasgho  223031589  73315.40
## 122         Iôlôniôrô  725287973 146762.40
## 123            Ipelsé  207573618  85814.34
## 124              Kaïn  752651438 132687.02
## 125           Kalsaka  590381124 122189.06
## 126            Kampti 1332824212 230862.40
## 127             Kando  352928753 140611.39
## 128           Kangala  524298579 142670.82
## 129         Kankalaba  314804630  78480.85
## 130         Kantchari 4114051518 310248.27
## 131 Karangasso-Sambla  765884090 169508.50
## 132  Karangasso-Vigué 1961595734 262445.03
## 133            Kassou 1209005628 182897.35
## 134           Kassoum  688993830 116075.60
## 135              Kaya  887327361 158554.59
## 136             Kayan  588746628 124876.62
## 137             Kayao  685271423 131588.13
## 138             Kelbo  506162502 120171.32
## 139          Kiembara  738797135 144398.83
## 140             Kindi  252631435  83809.81
## 141             Kirsi  224954675  80217.18
## 142             Koala 1366173451 197722.37
## 143             Kogho  242036636  82264.82
## 144          Kokologo  299803960 100710.01
## 145            Kôlôkô  748593593 176521.33
## 146        Kombissiri  589421858 139828.47
## 147           Kombori  220168850 101652.72
## 148       Komin-Yanga  827385895 148993.73
## 149       Komki-Ipala  218374274  67943.81
## 150         Kompienga  615627116 138918.81
## 151          Komsilga  344019730  93428.28
## 152          Komtoèga  208648812  90814.02
## 153              Kona  610118323 116626.10
## 154         Kongoussi  667256704 151221.35
## 155             Koper  427669084  96954.40
## 156            Kordié  452348124 124828.47
## 157         Korsimoro  643633001 166511.87
## 158          Kossouka  187513495  65090.96
## 159              Koti  710015138 153645.48
## 160            Koubri  571916041 151918.08
## 161         Koudougou  587811065 137165.96
## 162            Kougny  334701054  89456.96
## 163             Kouka  729362745 168226.61
## 164           Koumbia 1367365822 204311.38
## 165           Koumbri  628188331 139327.08
## 166        Koundougou  376753053 111363.62
## 167           Koupèla  335505440 161440.32
## 168         Kourinion  624933424 117096.11
## 169          Kourouma  981944402 143650.48
## 170         Koutougou 1886435680 216854.34
## 171            Kpuéré  542473220 114430.20
## 172              Kyon  196332617  79637.02
## 173          La-Toden  285693634  76179.80
## 174           Lalgaye  511714005 154119.15
## 175          Lanfièra  286164968  85309.03
## 176           Lankoué  296074466  83435.87
## 177              Laye  125941217  47753.05
## 178              Lèba  169901239  91662.82
## 179           Legmoin  260721985  91346.33
## 180              Lèna  613292504 132860.34
## 181               Léo  980165524 158340.17
## 182         Liptougou 1252789822 209315.82
## 183            Lôgbou 2348384269 344191.38
## 184          Loropéni 2100500135 262162.00
## 185           Loumana  492384910 136237.97
## 186          Loumbila  187508085  70722.47
## 187          Madjoari 1241398122 272754.87
## 188           Madouba  154714312  49536.37
## 189             Malba  196579602  81546.75
## 190              Mané  782477896 135505.63
## 191             Manga  218395993  74286.84
## 192         Mangodara 2564806897 331123.20
## 193              Mani 1274510258 217815.70
## 194           Mansila 1480330455 275907.96
## 195           Markoye 1221168056 185199.55
## 196        Matiakoali 4574267469 528136.37
## 197             Mégué  453615266 113641.56
## 198           Midebdo  548296336 138526.67
## 199           Môgtédo  593236847 164870.19
## 200           Morlaba  883949854 170830.97
## 201      Moussodougou  299766480  98180.21
## 202         Nagbingou  500789826  97843.68
## 203         Nagréongo  394619315 114648.14
## 204              Nako  710196158 196592.28
## 205      Namissiguima  342785017 109641.14
## 206      Namissiguima  442088101 107442.38
## 207           Namouno  125817089  77165.97
## 208          Nandiala  211957630  76189.45
## 209            Nanoro  343555667 143638.13
## 210           Nasséré  139528637  54732.80
## 211        Nassoumbou 1799185876 198391.73
## 212           Ndôrôla  818353980 165683.94
## 213     Nébiélianayou  379400075  91726.36
## 214          Niabouri  616712030 179001.59
## 215        Niangoloko 2802742001 368836.76
## 216    Niankôrôdougou  550484409 132659.27
## 217           Niaogho  216776256  76049.14
## 218             Niégo  163752711  58734.17
## 219              Niou  353195431 120044.57
## 220            Nobéré  594631830 145676.54
## 221             Nouna 1562820189 253673.04
## 222           Orodara  413446129  92731.00
## 223           Oronkua  383647143 106102.46
## 224       Ouagadougou  552875628 110342.65
## 225        Ouahigouya  503137686 125490.24
## 226          Ouargaye  532419093 143103.38
## 227          Ouarkoye 1071671453 160002.41
## 228           Ouéléni  398939218 117557.55
## 229            Ouéssa  191459129  60138.48
## 230         Ouindigui  631761811 125044.77
## 231              Oula  550487276 118579.50
## 232               Ouô 2566020652 461108.26
## 233     Ourgou-Manéga  370413583  97091.79
## 234              Ouri  664973372 149392.38
## 235             Oursi 1011727143 132536.78
## 236                Pâ  408616094 121344.06
## 237             Pabré  415294712 107767.68
## 238            Padéma  951921138 181299.23
## 239              Pama 5157942458 477753.91
## 240          Partiaga 1546120373 215594.22
## 241             Pella  224046757  67605.49
## 242              Péni 1255022143 220418.98
## 243             Pensa  919708450 176242.05
## 244          Périgban  295271020  92631.04
## 245           Pibaoré  454149142 139491.83
## 246             Piéla 1027363272 229181.61
## 247        Pilimpikou  178422439  76818.17
## 248           Pissila 1579777762 211126.15
## 249                Po 1586721423 225728.69
## 250               Poa  222104669  94716.57
## 251       Pobé-Mengao  553328019 113653.02
## 252            Pompoï  230442931  96605.59
## 253             Pouni  666716062 177314.27
## 254             Poura  102295797  51095.21
## 255         Pouytenga  170896656  96185.74
## 256             Rambo  293000764  85382.96
## 257           Ramongo  168470689  76463.09
## 258               Réo  428019134  93982.28
## 259             Rollo  570790219 102888.84
## 260             Roukô  120134842  49355.23
## 261             Saaba  560834493 109873.84
## 262             Sabou  466597162 176460.79
## 263             Sabsé  348252748 101858.94
## 264            Safané  978481716 209988.02
## 265             Samba  365725946 105070.25
## 266              Sami  578117634 135397.32
## 267       Samôgôgouan 1205028100 228206.44
## 268        Samôgôyiri  410052947 145433.81
## 269          Sampelga  538581206 143925.34
## 270            Sanaba  926063997 163632.92
## 271            Sangha  451260491 115496.86
## 272            Saolgo  282765442 138309.85
## 273            Saponé  630094152 158413.35
## 274            Sapouy 2072636036 259066.22
## 275            Satiri 1135574866 174822.74
## 276             Sebba 1148259332 244826.03
## 277        Senguènèga  677596365 136530.59
## 278          Seytenga  811634988 158497.39
## 279              Siby  279466674  81536.40
## 280      Sidéradougou 3631392396 450369.33
## 281             Siglé  298147393  71921.36
## 282             Silly 1227987621 225895.87
## 283             Sindo  624407791 146439.58
## 284            Sindou  406248986 102679.70
## 285               Soa  183461760  69080.12
## 286           Solenzo 1991124643 251784.32
## 287            Solhan  871954134 146260.54
## 288             Sollé  353347795 103721.97
## 289              Sônô  360976423 103643.49
## 290  Soubakaniédougou  867733484 182740.38
## 291         Soudougui 1803606438 218952.02
## 292           Sourgou  264583236  79854.55
## 293       Sourgoubila  481657837 116541.34
## 294           Tambaga  905292871 220326.40
## 295           Tangaye  516523439 142215.05
## 296  Tanguen-Dassouri  336003986  94359.08
## 297    Tankougounadié  790998365 147627.02
## 298          Tansarga  827185958 176547.31
## 299           Tansila 1064967932 210437.92
## 300          Tchériba 1314889978 206513.14
## 301            Ténado  888227592 165665.82
## 302         Tenkodogo 1209843034 238284.27
## 303     Tensobentenga  236408414  86516.97
## 304             Thion  321618396 110367.01
## 305             Thiou  294668987  96441.09
## 306             Thiou 1197388600 224744.43
## 307         Tiankoura  453271054 122922.52
## 308             Tibga  687835582 141874.06
## 309           Tiébélé  387030900 105840.21
## 310           Tiéfora 1396568730 251702.09
## 311            Tikaré  376027275 109193.04
## 312         Tin-Akoff 2391074541 307971.26
## 313            Titabè 1006862823 213037.24
## 314             Titao 1569266087 242120.63
## 315                To 1202493252 154270.67
## 316             Toécé  609133284 129994.25
## 317           Toèguen  202430634  78985.66
## 318             Toéni 1415553401 181007.87
## 319              Toma  446781069  92725.44
## 320        Tongomayel 2601310763 288972.60
## 321            Tougan 1754294074 191498.91
## 322             Tougo  316482658  98714.14
## 323          Tougouri 1637296237 219513.32
## 324         Toussiana  460839951  90729.40
## 325         Wolonkoto  257249852  70491.47
## 326              Yaba  718938981 141667.78
## 327              Yaho  382268394  94005.40
## 328              Yako  787420114 121880.66
## 329             Yalgo  569143863 138589.20
## 330             Yamba 1006066128 182719.51
## 331        Yargatenga  435546164 104124.97
## 332             Yargo  155208119  73107.81
## 333                Yé  761805675 140278.89
## 334             Yondé  645407304 127448.29
## 335             Zabré  957708270 173695.24
## 336               Zam  764907133 174900.54
## 337             Zambo  462635865 148241.17
## 338              Zamo  659387045 135557.03
## 339            Zawara  687668184 137034.67
## 340             Zecco   43978849  38882.10
## 341       Zéguédéguen  400217643 120333.71
## 342              Ziga  531391006 144846.41
## 343          Zimtanga  453545248 119115.93
## 344           Ziniaré  628489622 186621.15
## 345              Ziou  270166533 127818.16
## 346           Zitenga  390325738 105571.20
## 347             Zoaga  248856290  95653.36
## 348            Zogoré  234912509  84034.03
## 349             Zonsé  167780882  86266.80
## 350            Zôrgho  409957899 164639.63
## 351           Zoungou  324427708  97636.62

f. Affichage des données vectorielles

# Afficher les shapefiles en utilisant ggplot2

print("Affichage des données vectorielles :") 
## [1] "Affichage des données vectorielles :"
ggplot() + geom_sf(data = burkinafaso, fill = "lightblue", color = "black", alpha = 0.5) + geom_sf(data = regionbf, fill = NA, color = "red") + geom_sf(data = provincebf, fill = NA, color = "green") + geom_sf(data = communebf, fill = NA, color = "blue") + ggtitle("Carte des niveaux administratifs du Burkina Faso") + theme_minimal()

On va essayer de modifier l’étendue pour voir

# Définir une nouvelle étendue
ggplot() +
  geom_sf(data = burkinafaso) +
  coord_sf(xlim = c(-3, 3), ylim = c(10, 20)) # Modifier ces valeurs selon ton besoin

#Réimporter la base pour avoir l'étendue originale
burkinafaso <- st_read(paste0(chemin_base, "bfa_admbnda_adm0_igb_20200323.shp"))
## Reading layer `bfa_admbnda_adm0_igb_20200323' from data source 
##   `C:\Users\ALIOUNE KANE\Downloads\ENSAE\ISEP3\Statistiques exploratoire et spatiale\bfa_adm_igb_20200323_shp\bfa_admbnda_adm0_igb_20200323.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 1 feature and 10 fields
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: -5.511255 ymin: 9.415337 xmax: 2.407427 ymax: 15.08311
## Geodetic CRS:  WGS 84

Section 2 : Données raster

1.Importation des rasters

# Charger la bibliothèque nécessaire

library(raster) 
## Le chargement a nécessité le package : sp
## 
## Attachement du package : 'raster'
## L'objet suivant est masqué depuis 'package:dplyr':
## 
##     select
library(sp) 
library(leaflet)

# Dossier contenant le raster

chemin_dossier <- "C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina"

# Lister tous les fichiers raster dans le dossier avec l'extension .tiff

fichiers_raster <- list.files(chemin_dossier, pattern = "\\.(tiff)$", full.names = TRUE)

# Charger tous les rasters en tant que stack

rasters <- stack(fichiers_raster) 

print("Stack des rasters chargés :")
## [1] "Stack des rasters chargés :"
print(rasters)
## class      : RasterStack 
## dimensions : 136, 190, 25840, 46  (nrow, ncol, ncell, nlayers)
## resolution : 0.04166667, 0.04165069  (x, y)
## extent     : -5.5, 2.416667, 9.433585, 15.09808  (xmin, xmax, ymin, ymax)
## crs        : +proj=longlat +datum=WGS84 +no_defs 
## names      : X202406_G//A_2000_1.1, X202406_G//A_2000_1.2, X202406_G//A_2001_1.1, X202406_G//A_2001_1.2, X202406_G//A_2002_1.1, X202406_G//A_2002_1.2, X202406_G//A_2003_1.1, X202406_G//A_2003_1.2, X202406_G//A_2004_1.1, X202406_G//A_2004_1.2, X202406_G//A_2005_1.1, X202406_G//A_2005_1.2, X202406_G//A_2006_1.1, X202406_G//A_2006_1.2, X202406_G//A_2007_1.1, ...
# Visualiser les fichiers raster un par un

for (fichier in fichiers_raster) { raster_obj <- raster(fichier) 
print(paste("Visualisation de :", fichier))}
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2000.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2001.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2002.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2003.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2004.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2005.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2006.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2007.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2008.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2009.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2010.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2011.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2012.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2013.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2014.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2015.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2016.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2017.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2018.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2019.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2020.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2021.tiff"
## [1] "Visualisation de : C:/Users/ALIOUNE KANE/Downloads/Stage ANSD/Statistique Exploratoire et Spatiale/Abson-dev Statistique-Exploratoire-Spatiale main TP2-data_Malaria_Burkina/202406_Global_Pf_Parasite_Rate_BFA_2022.tiff"
# Visualiser le raster plot(raster_obj, main = paste("Visualisation de :", basename(fichier)))

# Pause pour permettre à l'utilisateur de voir chaque raster avant de continuer readline(prompt = "Appuyez sur Entrée pour voir le fichier suivant...") }

2. Calculs de statistiques (en ignorant les NA)

# a. Moyenne

mean_raster <- calc(rasters, fun = mean, na.rm = TRUE)
print("Moyenne calculée :") 
## [1] "Moyenne calculée :"
plot(mean_raster)

# b. Médiane

median_raster <- calc(rasters, fun = median, na.rm = TRUE) 
print("Médiane calculée :") 
## [1] "Médiane calculée :"
plot(median_raster)

# c. Ecart-type

sd_raster <- calc(rasters, fun = sd, na.rm = TRUE) 
print("Ecart-type calculé :") 
## [1] "Ecart-type calculé :"
plot(sd_raster)

# d. Minimum et maximum

min_raster <- calc(rasters, fun = min, na.rm = TRUE) 
## Warning in FUN(newX[, i], ...): aucun argument trouvé pour min ; Inf est
## renvoyé
## Warning in FUN(newX[, i], ...): aucun argument trouvé pour min ; Inf est
## renvoyé
## Warning in FUN(newX[, i], ...): aucun argument trouvé pour min ; Inf est
## renvoyé
## Warning in FUN(newX[, i], ...): aucun argument trouvé pour min ; Inf est
## renvoyé
## Warning in FUN(newX[, i], ...): aucun argument trouvé pour min ; Inf est
## renvoyé
print("Minimum calculé :")
## [1] "Minimum calculé :"
plot(min_raster)

max_raster <- calc(rasters, fun = max, na.rm = TRUE) 
## Warning in FUN(newX[, i], ...): aucun argument pour max ; -Inf est renvoyé
## Warning in FUN(newX[, i], ...): aucun argument pour max ; -Inf est renvoyé
## Warning in FUN(newX[, i], ...): aucun argument pour max ; -Inf est renvoyé
## Warning in FUN(newX[, i], ...): aucun argument pour max ; -Inf est renvoyé
## Warning in FUN(newX[, i], ...): aucun argument pour max ; -Inf est renvoyé
print("Maximum calculé :") 
## [1] "Maximum calculé :"
plot(max_raster)

# Fonction pour créer une carte interactive avec leaflet
create_interactive_map <- function(raster_layer, title) {
  # Convertir le raster en SpatialPixelsDataFrame pour leaflet
  raster_spdf <- as(raster_layer, "SpatialPixelsDataFrame")
  
  # Créer un data frame à partir du raster pour leaflet
  raster_df <- as.data.frame(raster_spdf)
  colnames(raster_df) <- c("value", "x", "y")
  
  # Créer la carte avec leaflet
  leaflet() %>%
    addTiles() %>%
    addCircleMarkers(data = raster_df, lng = ~x, lat = ~y, radius = 2,
                     color = ~ifelse(is.na(value), "transparent", "blue"),
                     fillOpacity = 0.5, stroke = FALSE) %>%
    addLegend("bottomright", title = title, values = raster_df$value,
              pal = colorNumeric(palette = "viridis", domain = raster_df$value),
              na.label = "NA") %>%
    setView(lng = mean(raster_df$x, na.rm = TRUE), lat = mean(raster_df$y, na.rm = TRUE), zoom = 6)
}
# a. Visualisation interactive de la moyenne

create_interactive_map(mean_raster, "Moyenne des Rasters")
# b. Visualisation interactive de la médiane

create_interactive_map(median_raster, "Médiane des Rasters")
# c. Visualisation interactive de l'écart-type

create_interactive_map(sd_raster, "Ecart-Type des Rasters")
# d. Visualisation interactive du minimum

create_interactive_map(min_raster, "Minimum des Rasters")
# e. Visualisation interactive du maximum

create_interactive_map(max_raster, "Maximum des Rasters")